package cn.topevery.garden.dal.logic;

import cn.topevery.garden.dal.dao.TaskPersonRelationDao;
import cn.topevery.garden.entity.po.TaskPersonRelation;
import cn.topevery.garden.entity.query.TaskPersonRelationQuery;
import cn.topevery.garden.entity.vo.TaskPersonRelationVO;
import cn.topevery.garden.framework.base.BaseLogic;
import hw.topevery.framework.db.base.BaseEntityDao;
import hw.topevery.framework.db.entity.DataPager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 人员任务关系表
 *
 * @author code-generate
 * @date 2021-09-02
 */
@Service
public class TaskPersonRelationLogic extends BaseLogic<TaskPersonRelation> {
    @Autowired
    TaskPersonRelationDao taskPersonRelationDao;

    @Override
    public BaseEntityDao<TaskPersonRelation, Integer> getDao() {
        return taskPersonRelationDao;
    }

    

    /**
     * 获取列表
     *
     * @param query
     */
    public DataPager<TaskPersonRelationVO> listPage(TaskPersonRelationQuery query) {
        return taskPersonRelationDao.listPage(query);
    }

    /**
     * 根据自增id批量删除
     *
     * @param ids
     */
    public void deleteBatchById(String userId,Integer[] ids) {
        taskPersonRelationDao.delete(userId, ids);
    }

    /**
     * 根据自增id保存或者更新
     *
     * @param taskPersonRelation 实体
     */
    public void saveOrUpdate(String userId, TaskPersonRelation taskPersonRelation){
        taskPersonRelationDao.saveOrUpdate(userId,taskPersonRelation);
    }

    public void deleteByTaskId(Integer userId, Integer taskId) {
        taskPersonRelationDao.deleteByTaskId(userId, taskId);
    }

    public void deleteByUserId(Integer userId) {
        taskPersonRelationDao.deleteByUserId(userId);
    }

    public TaskPersonRelation getByPersonId(Integer personId) {
        return taskPersonRelationDao.getByPersonId(personId);
    }

    public TaskPersonRelation getByTaskId(Integer taskId) {
        return taskPersonRelationDao.getByTaskId(taskId);
    }
}
